<?php
namespace app\controllers;

use fastphp\base\Controller;
use app\models\Record;
use app\models\Error;

class RecordController extends Controller
{
    public function index()
    {
        $nowPage = is_numeric(@$_GET['page'])?@$_GET['page']:1;
        $this->assign('title', '记录列表');
        $this->assign('page', $nowPage);
        $this->assign('list', (new Record())->list($nowPage, 20, true));
        $this->assign('total', $total=(new Record())->count());
        $this->assign('pages', (int)($total/20));
        $this->render();
    }
    public function show($id = null)
    {
        if (!($record = (new Record())->get($id))) {
            Error::error(404);
        }
        $this->assign('title', '评测记录 #' . $record['submitid']);
        $this->assign('record', $record);
        $this->render();
    }
}